////////////////////////////////////////////////////////////////////////////////
// Includes
////////////////////////////////////////////////////////////////////////////////

var webconfig = require('../webconfig');
var express = require('express');
var router = express.Router();
var session = require('express-session')

/* GET home page. */
router.get('/', function (req, res, next) {
    //Session.regenerate();
    //req.session.views['/foo'] = 0;
    
    // Sample code for usage of session
    
    if (req.session) {
        console.log("has session obj");
    } else {
        console.log("session obj MISSING");
    }
    
    var views = req.session.views;

    if (!views) {
        console.log("VIEWS NOT EXISTS");
        views = req.session.views = {}
    } else {
        console.log("VIEWS EXISTS");
    }
    
    views["asd"] = "ok";
    
    // ------------------------------
    

    // get the url pathname
    //var pathname = parseurl(req).pathname

    // count the views
    //views[pathname] = (views[pathname] || 0) + 1
    
    res.render(
        './home/index', {
             title: 'Project Radar'
        }
    );
});


/* GET dashboard. */
router.get('/dashboard', function (req, res, next) {
    res.render(
        './home/dashboard', {
             title: 'Project Radar'
        }
    );
});

/* GET about. */
router.get('/about', function (req, res, next) {
    res.render(
        './home/about', {
             title: 'Project Radar'
        }
    );
});

/* GET contact. */
router.get('/contact', function (req, res, next) {
    res.render(
        './home/contact', {
             title: 'Project Radar'
        }
    );
});

module.exports = router;
